package com.qili.core.utils;

import com.qili.entity.base.BaseDict;
import com.qili.entity.supervisor.SupervisorFile;
import com.qili.service.supervisor.SupervisorFileService;
import com.qili.util.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContext;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FileUtils {
    /**
     * @param pUploadType
     * @param pFileConfigId
     * @param pPrjName
     * @param pFileType
     * @param pFbCode
     * @param pFileStuffix
     * @param pFileNo
     * @Description:根据文件类型获取存储文件名称
     * @Author:Zhangshuo
     * @Date:20:24 2020-12-10
     */
    public static String getSaveFullFileName(int pUploadType, String pFileConfigId, String pPrjName, String pFileType, String pFbCode, String pFileStuffix, String pFileNo) {
        UploadType uploadType = UploadType.getEnumByType(pUploadType);
        uploadType.setFilePathId(pFileConfigId);
        String AsFileName = FileUtils.getFileNameByNo(pPrjName, pFileType, pFbCode, pFileStuffix, pFileNo);
        uploadType.setFileName(AsFileName);
        uploadType.appendPlaceHolder(pPrjName);
        uploadType.appendPlaceHolder(pFbCode);

        return FilePathUtil.getFullSavePathAndNameByConfigFileId(uploadType);
    }

    /**
     * @param pUploadType
     * @param pFileConfigId
     * @param pPrjName
     * @param pFileType
     * @param pFbCode
     * @param pFileStuffix
     * @param pFileNo
     * @Description:根据文件类型获取存储文件名称
     * @Author:Zhangshuo
     * @Date:20:24 2020-12-10
     */
    public static String getSaveFullImageFileName(int pUploadType, String pFileConfigId, String pPrjName, String pFileType, String pFbCode, String pFileStuffix, String pFileNo) {
        UploadType uploadType = UploadType.getEnumByType(pUploadType);
        uploadType.setFilePathId(pFileConfigId);
        String AsFileName = FileUtils.getFileNameByNo(pPrjName, pFileType, pFbCode, pFileStuffix, pFileNo);
        uploadType.setFileName(AsFileName);
        uploadType.appendPlaceHolder(pPrjName);
        uploadType.appendPlaceHolder(pFbCode);

        return FilePathUtil.getFullSavePathAndNameByConfigFileId(uploadType);
    }

    /**
     * @param AsPrjName     项目名称
     * @param psFbCode      分包编号
     * @param psFileType    文件类型
     * @param psFileStuffix 文件后缀名
     * @Description:根据文件类型 获取文件名称 项目章授权书_001_20201130_济南市智能项目_A1
     * @Author:Zhangshuo
     * @Date:9:59 2020/12/4
     */
    public static String getFileNameByNo(String AsPrjName, String psFileType, String psFbCode, String psFileStuffix, String pNo) {
        //分包编号
        String AsFbCode = psFbCode;
        //根据文件
        BaseDict AoDict = DictUtil.getDictByCode(DictTypes.WJ, psFileType);
        String AsFileName = AoDict.getBadtName() + "_" + pNo + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsPrjName;
        if (StringUtil.isNotBlank(AsFbCode)) {
            AsFileName = AsFileName + "_" + AsFbCode;
        }
        AsFileName = AsFileName + psFileStuffix;
        return AsFileName;
    }

    public static String getFileNameByNoJc(String AsPrjName, String psFileType, String psFbCode, String psFileStuffix, String pNo) {
        //分包编号
        String AsFbCode = psFbCode;
        //根据文件
        BaseDict AoDict = DictUtil.getDictByCode(DictTypes.WJJC, psFileType);
        String AsFileName = AoDict.getBadtName() + "_" + pNo + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsPrjName;
        if (StringUtil.isNotBlank(AsFbCode)) {
            AsFileName = AsFileName + "_" + AsFbCode;
        }
        AsFileName = AsFileName + psFileStuffix;
        return AsFileName;
    }

    public static String getFileNameByNoZx(String AsPrjName, String psFileType, String psFbCode, String psFileStuffix, String pNo) {
        //分包编号
        String AsFbCode = psFbCode;
        //根据文件
        BaseDict AoDict = DictUtil.getDictByCode(DictTypes.WJZX, psFileType);
        String AsFileName = AoDict.getBadtName() + "_" + pNo + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsPrjName;
        if (StringUtil.isNotBlank(AsFbCode)) {
            AsFileName = AsFileName + "_" + AsFbCode;
        }
        AsFileName = AsFileName + psFileStuffix;
        return AsFileName;
    }


    /**
     * @param AsPrjName
     * @param psFileType
     * @param pFbCode
     * @param psFileStuffix
     * @param piFileCount     限制文件数量
     * @param pSupervisorFile
     * @param pUploadType     上传类型（001：普通文件上传，002 文件中的图片上传）
     * @param pPositionName   部位
     * @Description:根据文件类型 获取文件名称 项目章授权书_001_20201130_济南市智能项目_A1
     * @Author:Zhangshuo
     * @Date:0:06 2020-12-19
     */
    public static String getFileName(String AsPrjName, String psFileType, String pFbCode, String psFileStuffix, int piFileCount, SupervisorFile pSupervisorFile, String pUploadType, String pPositionName) {
        //分包编号
        String AsFbCode = pFbCode;
        //获取顺序号
        String AsNo = getFileOrderCode(piFileCount, pSupervisorFile);
        return getFileNameByType(AsPrjName, psFileType, psFileStuffix, pUploadType, pPositionName, AsFbCode, AsNo);
    }

    public static String getFileNameZx(String AsPrjName, String psFileType, String pFbCode, String psFileStuffix, int piFileCount, SupervisorFile pSupervisorFile, String pUploadType, String pPositionName) {
        //分包编号
        String AsFbCode = pFbCode;
        //获取顺序号
        String AsNo = getFileOrderCode(piFileCount, pSupervisorFile);
        return getFileNameByTypeZx(AsPrjName, psFileType, psFileStuffix, pUploadType, pPositionName, AsFbCode, AsNo);
    }

    /**
     * @param AsPrjName
     * @param psFileType
     * @param psFileStuffix
     * @param pUploadType
     * @param pPositionName
     * @param AsFbCode
     * @param AsNo
     * @Description: 根据文件类型获取文件名称
     * @Author:Zhangshuo
     * @Date:21:47 2020-12-20
     */
    private static String getFileNameByType(String AsPrjName, String psFileType, String psFileStuffix, String pUploadType, String pPositionName, String AsFbCode, String AsNo) {
        if ((("036".equals(psFileType) || "037".equals(psFileType)|| "106".equals(psFileType)) && ("002".equals(pUploadType))) || ("043".equals(psFileType) && ("001".equals(pUploadType)))) {
            return AsFbCode + "_" + pPositionName + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsNo + psFileStuffix;
        } else if ((("109".equals(psFileType) || "088".equals(psFileType)) && ("002".equals(pUploadType)))) {
            return pPositionName + "_" + AsNo;
        } else if ((("108".equals(psFileType) || "087".equals(psFileType)) && ("002".equals(pUploadType)))) {
            return AsFbCode + "_" + pPositionName + "_" + AsNo;
        }else if((("093".equals(psFileType)) && ("002".equals(pUploadType)))){
            return AsFbCode + "_" + DateUtil.getCurrentDateNoSpliter()  + "_" + AsNo+psFileStuffix;
        }else if((("040".equals(psFileType)) && ("002".equals(pUploadType)))){
            return  AsFbCode + "_开箱检验附件"+DateUtil.getCurrentDateTimeStringNoSpliter()  + "_" + AsNo+psFileStuffix;
        } else {
            //根据文件
            BaseDict AoDict = DictUtil.getDictByCode(DictTypes.WJ, psFileType);
            String AsFileName = AoDict.getBadtName() + "_" + AsNo + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsPrjName;
            if (StringUtil.isNotBlank(AsFbCode)) {
                AsFileName = AsFileName + "_" + AsFbCode;
            }
            if("055".equals(psFileType)){
                AsFileName=AsFileName+"_初验";
            }else if("061".equals(psFileType)){
                AsFileName=AsFileName+"_终验";
            }else if("076".equals(psFileType)){
                AsFileName=AsFileName+"_终验";
            }else if("075".equals(psFileType)){
                AsFileName=AsFileName+"_初验";
            }else if("082".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else if("084".equals(psFileType)){
                AsFileName=AsFileName+"_项目会议";
            }else if("054".equals(psFileType)){
                /*监理工作总结报告*/
                AsFileName=AsFileName+"_初验";
            }else if("060".equals(psFileType)){
                /*监理工作总结报告*/
                AsFileName=AsFileName+"_终验";
            }else if("080".equals(psFileType)){
                /*监理工作总结报告*/
                AsFileName=AsFileName+"_验收";
            }else if("084".equals(psFileType)){
                /*其他监理工作 项目会议 会议纪要 */
                AsFileName=AsFileName+"_项目会议";
            }else if("053".equals(psFileType)){
                /*文档审核报告*/
                AsFileName=AsFileName+"_初验";
            }else  if("079".equals(psFileType)){
                /*文档审核报告*/
                AsFileName=AsFileName+"_验收";
            }else if("035".equals(psFileType)){
                /*监理审核报告*/
                AsFileName=AsFileName+"_深化设计文件";
            }else if("027".equals(psFileType)){
                /*监理审核报告*/
                AsFileName=AsFileName+"_需求文件";
            }else if("031".equals(psFileType)){
                /*监理审核报告*/
                AsFileName=AsFileName+"_设计文件";
            }
            /* else if("110".equals(psFileType)){
             *//*支付意见*//*
                AsFileName=AsFileName+"_验收";
            }*/else if("089".equals(psFileType)){
                /*支付意见*/
                AsFileName=AsFileName+"_其他监理工作";
            }else if("108".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else if("109".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else if("110".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else  if("072".equals(psFileType)){
                /*承建单位自检报告*/
                AsFileName=AsFileName+"_检验检测";
            }else if("048".equals(psFileType)){
                /*承建单位自检报告*/
                AsFileName=AsFileName+"_检验评估";
            }else if("106".equals(psFileType)){
                /*检查评审*/
                AsFileName=AsFileName+"_检查评审";
            }else if("022".equals(psFileType)){
                AsFileName=AsFileName+"_设计";
            }else if("066".equals(psFileType)){
                AsFileName=AsFileName+"_实施";
            }else if("026".equals(psFileType)){
                AsFileName=AsFileName+"_需求文件";
            }else if("030".equals(psFileType)){
                AsFileName=AsFileName+"_设计文件";
            }else if("034".equals(psFileType)){
                AsFileName=AsFileName+"_深化设计文件";
            }else if("065".equals(psFileType)){
                AsFileName=AsFileName+"_设计";
            }else if("070".equals(psFileType)){
                AsFileName=AsFileName+"_实施";
            }

            AsFileName = AsFileName + psFileStuffix;
            return AsFileName;
        }
    }

    /**
     * @param AsPrjName
     * @param psFileType
     * @param psFileStuffix
     * @param pUploadType
     * @param pPositionName
     * @param AsFbCode
     * @param AsNo
     * @Description: 根据文件类型获取文件名称
     * @Author:Zhangshuo
     * @Date:21:47 2020-12-20
     */
    private static String getFileNameByTypeZx(String AsPrjName, String psFileType, String psFileStuffix, String pUploadType, String pPositionName, String AsFbCode, String AsNo) {
        if ((("036".equals(psFileType) || "037".equals(psFileType)|| "106".equals(psFileType)) && ("002".equals(pUploadType))) || ("043".equals(psFileType) && ("001".equals(pUploadType)))) {
            return AsFbCode + "_" + pPositionName + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsNo + psFileStuffix;
        } else if ((("020".equals(psFileType) ) && ("002".equals(pUploadType)))) {
            return pPositionName + "_" + AsNo;
        } else if ((("108".equals(psFileType) || "087".equals(psFileType)) && ("002".equals(pUploadType)))) {
            return AsFbCode + "_" + pPositionName + "_" + AsNo;
        }else if((("093".equals(psFileType)) && ("002".equals(pUploadType)))){
            return AsFbCode + "_" + DateUtil.getCurrentDateNoSpliter()  + "_" + AsNo+psFileStuffix;
        }else if((("040".equals(psFileType)) && ("002".equals(pUploadType)))){
            return  AsFbCode + "_开箱检验附件"+DateUtil.getCurrentDateTimeStringNoSpliter()  + "_" + AsNo+psFileStuffix;
        } else {
            //根据文件
            BaseDict AoDict = DictUtil.getDictByCode(DictTypes.WJZX, psFileType);
            String AsFileName = AoDict.getBadtName() + "_" + AsNo + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + AsPrjName;
            if (StringUtil.isNotBlank(AsFbCode)) {
                AsFileName = AsFileName + "_" + AsFbCode;
            }
            if("055".equals(psFileType)){
                AsFileName=AsFileName+"_初验";
            }else if("061".equals(psFileType)){
                AsFileName=AsFileName+"_终验";
            }else if("076".equals(psFileType)){
                AsFileName=AsFileName+"_终验";
            }else if("075".equals(psFileType)){
                AsFileName=AsFileName+"_初验";
            }else if("082".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else if("084".equals(psFileType)){
                AsFileName=AsFileName+"_项目会议";
            }else if("054".equals(psFileType)){
                /*监理工作总结报告*/
                AsFileName=AsFileName+"_初验";
            }else if("060".equals(psFileType)){
                /*监理工作总结报告*/
                AsFileName=AsFileName+"_终验";
            }else if("080".equals(psFileType)){
                /*监理工作总结报告*/
                AsFileName=AsFileName+"_验收";
            }else if("084".equals(psFileType)){
                /*其他监理工作 项目会议 会议纪要 */
                AsFileName=AsFileName+"_项目会议";
            }else if("053".equals(psFileType)){
                /*文档审核报告*/
                AsFileName=AsFileName+"_初验";
            }else  if("079".equals(psFileType)){
                /*文档审核报告*/
                AsFileName=AsFileName+"_验收";
            }else if("035".equals(psFileType)){
                /*监理审核报告*/
                AsFileName=AsFileName+"_深化设计文件";
            }else if("027".equals(psFileType)){
                /*监理审核报告*/
                AsFileName=AsFileName+"_需求文件";
            }else if("031".equals(psFileType)){
                /*监理审核报告*/
                AsFileName=AsFileName+"_设计文件";
            }
            /* else if("110".equals(psFileType)){
             *//*支付意见*//*
                AsFileName=AsFileName+"_验收";
            }*/else if("089".equals(psFileType)){
                /*支付意见*/
                AsFileName=AsFileName+"_其他监理工作";
            }else if("108".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else if("109".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else if("110".equals(psFileType)){
                AsFileName=AsFileName+"_验收";
            }else  if("072".equals(psFileType)){
                /*承建单位自检报告*/
                AsFileName=AsFileName+"_检验检测";
            }else if("048".equals(psFileType)){
                /*承建单位自检报告*/
                AsFileName=AsFileName+"_检验评估";
            }else if("106".equals(psFileType)){
                /*检查评审*/
                AsFileName=AsFileName+"_检查评审";
            }else if("022".equals(psFileType)){
                AsFileName=AsFileName+"_设计";
            }else if("066".equals(psFileType)){
                AsFileName=AsFileName+"_实施";
            }else if("026".equals(psFileType)){
                AsFileName=AsFileName+"_需求文件";
            }else if("034".equals(psFileType)){
                AsFileName=AsFileName+"_深化设计文件";
            }else if("065".equals(psFileType)){
                AsFileName=AsFileName+"_设计";
            }else if("070".equals(psFileType)){
                AsFileName=AsFileName+"_实施";
            }

            AsFileName = AsFileName + psFileStuffix;
            return AsFileName;
        }
    }


    /**
     * @param poSupervisor
     * @Author:Zhangshuo
     * @Description:
     * @Date:12:31 2020/12/4
     */
    public static String getFileOrderCode(int piFileCount, SupervisorFile poSupervisor) {
        ApplicationContext context = SpringUtil.getApplicationContext();
        SupervisorFileService supervisorFileService = context.getBean(SupervisorFileService.class);
        Integer count=0;
        Map paraMap = new HashMap<>();
        if(StringUtil.isNotBlank(poSupervisor.getProjectId())){
            paraMap.put("projectId", poSupervisor.getProjectId());
        }
        if("055".equals(poSupervisor.getType())||"061".equals(poSupervisor.getType())||"081".equals(poSupervisor.getType())){
            List<String> typeList = new ArrayList<String>();
            typeList.add("055");
            typeList.add("061");
            typeList.add("081");
            paraMap.put("typeList",typeList);
        }else if("036".equals(poSupervisor.getType()) || "037".equals(poSupervisor.getType())){
            List<String> typeList = new ArrayList<String>();
            typeList.add("036");
            typeList.add("037");
            paraMap.put("type", poSupervisor.getType());
        }else if("093".equals(poSupervisor.getType())){
            /*变更处理有附件  所以查询主文件需要 添加parentId为空*/
            paraMap.put("type", poSupervisor.getType());
            paraMap.put("spmId", poSupervisor.getSpmId());
            paraMap.put("pcId", poSupervisor.getPcId());
            //parentId不为空
            paraMap.put("parentIdNull", "111");
        }else{
            if(StringUtils.isBlank(poSupervisor.getPcId())){
                poSupervisor.setPcId(null);
                //paraMap.put("pcIdNull","pcIdNull");
            }else{
                paraMap.put("pcId", poSupervisor.getPcId());
            }
            if(StringUtils.isNotBlank(poSupervisor.getParentId())){
                paraMap.put("parentId", poSupervisor.getParentId());
            }
            if(StringUtils.isNotBlank(poSupervisor.getSpmId())){
                paraMap.put("spmId", poSupervisor.getSpmId());
            }
            if(StringUtil.isNotBlank(poSupervisor.getType())){
                paraMap.put("type", poSupervisor.getType());
            }

        }
        count = supervisorFileService.selectMaxOrderBySupervisorFile(paraMap)+1;
        poSupervisor.setInd(count);
//        if (piFileCount >=count) {
//            count = piFileCount;
//        }
        NumberFormat formatter = new DecimalFormat("000");
        String AsOrderNum = formatter.format(count);
        return AsOrderNum;
    }

    /**
     * @param pSourceFile
     * @param pTargetFile
     * @Author:Zhangshuo
     * @Description: 复制文件到指定目录
     * @Date:14:33 2020-12-09
     */
    public static boolean CopyFile(String pSourceFile, String pTargetFile) {
        File dest = new File(pTargetFile);
        File destDir = new File(dest.getParent());
        if (!(destDir.exists() && destDir.isDirectory())) {
            destDir.mkdirs();
        }

        File source = new File(pSourceFile);
        try {
            Files.copy(source.toPath(), dest.toPath(), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
            return true;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return false;
        }
    }

    // 删除某个目录及目录下的所有子目录和文件
    public static boolean deleteDir(File dir) {
        // 如果是文件夹
        if (dir.isDirectory()) {
            // 则读出该文件夹下的的所有文件
            String[] children = dir.list();
            // 递归删除目录中的子目录下
            for (int i = 0; i < children.length; i++) {
                // File f=new File（String parent ，String child）
                // parent抽象路径名用于表示目录，child 路径名字符串用于表示目录或文件。
                // 连起来刚好是文件路径
                boolean isDelete = deleteDir(new File(dir, children[i]));
                // 如果删完了，没东西删，isDelete==false的时候，则跳出此时递归
                if (!isDelete) {
                    return false;
                }
            }
        }
        // 读到的是一个文件或者是一个空目录，则可以直接删除
        return dir.delete();
    }

    // 复制某个目录及目录下的所有子目录和文件到新文件夹
    public static void copyFolder(String oldPath, String newPath) throws IOException {
        // 如果文件夹不存在，则建立新文件夹
        (new File(newPath)).mkdirs();
        // 读取整个文件夹的内容到file字符串数组，下面设置一个游标i，不停地向下移开始读这个数组
        File filelist = new File(oldPath);
        String[] file = filelist.list();
        // 要注意，这个temp仅仅是一个临时文件指针
        // 整个程序并没有创建临时文件
        File temp = null;
        for (int i = 0; i < file.length; i++) {
            // 如果oldPath以路径分隔符/或者\结尾，那么则oldPath/文件名就可以了
            // 否则要自己oldPath后面补个路径分隔符再加文件名
            // 谁知道你传递过来的参数是f:/a还是f:/a/啊？
            if (oldPath.endsWith(File.separator)) {
                temp = new File(oldPath + file[i]);
            } else {
                temp = new File(oldPath + File.separator + file[i]);
            }

            // 如果游标遇到文件
            if (temp.isFile()) {
                FileInputStream input = new FileInputStream(temp);
                // 复制并且改名
                FileOutputStream output = new FileOutputStream(newPath
                        + File.separator + (temp.getName()).toString());
                byte[] bufferarray = new byte[1024 * 64];
                int prereadlength;
                while ((prereadlength = input.read(bufferarray)) != -1) {
                    output.write(bufferarray, 0, prereadlength);
                }
                output.flush();
                output.close();
                input.close();
            }
            // 如果游标遇到文件夹
            if (temp.isDirectory()) {
                copyFolder(oldPath + "/" + file[i], newPath + "/" + file[i]);
            }
        }
    }

    /**
     * 移动文件夹
     * @param oldPath
     * @param newPath
     */
    public static void moveFolder(String oldPath, String newPath) {
        // 先复制文件
        try{
            copyFolder(oldPath, newPath);
            // 则删除源文件，以免复制的时候错乱
            deleteDir(new File(oldPath));
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static String getFileNameJc(String psPrjName, String psFileType, String psFbCode, String psFileStuffix, int piFileCount, SupervisorFile poSupervisorFile, String pUploadType, String pPositionName) {
        //分包编号
        String AsFbCode = psFbCode;
        //获取顺序号
        String AsNo = getFileOrderCode(piFileCount, poSupervisorFile);
        return getFileNameByTypeJc(psPrjName, psFileType, psFileStuffix, pUploadType, pPositionName, AsFbCode, AsNo);

    }

    private static String getFileNameByTypeJc(String psPrjName, String psFileType, String psFileStuffix, String pUploadType, String pPositionName, String AsFbCode, String asNo) {
        if ((("036".equals(psFileType) || "037".equals(psFileType)|| "106".equals(psFileType)) && ("002".equals(pUploadType))) || ("043".equals(psFileType) && ("001".equals(pUploadType)))) {
            return AsFbCode + "_" + pPositionName + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + asNo + psFileStuffix;
        } else if ((("020".equals(psFileType) ) && ("002".equals(pUploadType)))) {
            return pPositionName + "_" + asNo;
        } else if ((("108".equals(psFileType) || "087".equals(psFileType)) && ("002".equals(pUploadType)))) {
            return AsFbCode + "_" + pPositionName + "_" + asNo;
        }else if((("093".equals(psFileType)) && ("002".equals(pUploadType)))){
            return AsFbCode + "_" + DateUtil.getCurrentDateNoSpliter()  + "_" + asNo+psFileStuffix;
        }else if((("040".equals(psFileType)) && ("002".equals(pUploadType)))){
            return  AsFbCode + "_开箱检验附件"+DateUtil.getCurrentDateTimeStringNoSpliter()  + "_" + asNo+psFileStuffix;
        } else {
            //根据文件
            BaseDict AoDict = DictUtil.getDictByCode(DictTypes.WJJC, psFileType);
            String AsFileName = AoDict.getBadtName() + "_" + asNo + "_" + DateUtil.getCurrentDateNoSpliter() + "_" + psPrjName;
            if (StringUtil.isNotBlank(AsFbCode)) {
                AsFileName = AsFileName + "_" + AsFbCode;
            }
            if("029".equals(psFileType)){
                AsFileName=AsFileName+"_项目会议";
            }else if("030".equals(psFileType)){
                AsFileName=AsFileName+"_项目会议";
            }
            AsFileName = AsFileName + psFileStuffix;
            return AsFileName;
        }
    }

    public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";

    /**
     * 文件名称验证
     *
     * @param filename 文件名称
     * @return true 正常 false 非法
     */
    public static boolean isValidFilename(String filename)
    {
        return filename.matches(FILENAME_PATTERN);
    }



}
